const express = require("express");
let app = express();
const HttpProxy = require("http-proxy");
let apiProxy = HttpProxy.createProxyServer();

app.all(["/r*"], function (req, res) {
    if (req.path.startsWith("/r/")) {
        req.url = req.url.replace(/^(\/r)/, "")
        apiProxy.web(req, res, {
            target: "http://localhost:3000",//ghorizon的本地运行路径..
            changeOrigin: true
        })
    } else {
        "那么肯定是hostname.com/r了"
        res.redirect(307,"./r/")
    }

});

app.listen(3001);